<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>递归求和</title>
</head>
<body>
    <script>
        function sum(...args) {
            if(args.length == 0){
                return 0;
            }
            return args.pop() + sum(...args);

            // 简写
            // return (args.length == 0) ? 0 : (args.pop() + sum(...args));
        }

        console.log(sum(1,4,6,7,3));
    </script>
</body>
</html>